﻿<%@ Page Title="" Language="VB" MasterPageFile="~/manage/MasterPage.master" AutoEventWireup="false" CodeFile="company.aspx.vb" Inherits="manage_company" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
    <p>
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="company" DataSourceID="SqlDataSource1" CellPadding="4" ForeColor="#333333" GridLines="None" PageSize="20">
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <Columns>
            <asp:CommandField ShowSelectButton="True" />
            <asp:BoundField DataField="company" HeaderText="company" ReadOnly="True" SortExpression="company" >
            <HeaderStyle Width="150px" />
            </asp:BoundField>
            <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" >
            <HeaderStyle Width="200px" />
            <ItemStyle Width="200px" />
            </asp:BoundField>
            <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
            <asp:BoundField DataField="ContactPerson" HeaderText="ContactPerson" SortExpression="ContactPerson" />
            <asp:BoundField DataField="Work" HeaderText="Work" SortExpression="Work" />
            <asp:BoundField DataField="Mobile" HeaderText="Mobile" SortExpression="Mobile" />
            <asp:BoundField DataField="Comments" HeaderText="Comments" SortExpression="Comments" Visible="False" />
            <asp:BoundField DataField="AssignedAgent" HeaderText="AssignedAgent" SortExpression="AssignedAgent" />
        </Columns>
        <EditRowStyle BackColor="#999999" />
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#E9E7E2" />
        <SortedAscendingHeaderStyle BackColor="#506C8C" />
        <SortedDescendingCellStyle BackColor="#FFFDF8" />
        <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
    </asp:GridView>
    <br />
        <asp:FormView ID="FormView1" runat="server" AllowPaging="True" DataKeyNames="company" DataSourceID="SqlDataSource1">
            <EditItemTemplate>
                <table style="width: 100%;">
                    <tr>
                        <td>company: </td>
                        <td>
                            <asp:Label ID="companyLabel1" runat="server" Text='<%# Eval("company") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>Address:</td>
                        <td>
                            <asp:TextBox ID="AddressTextBox" runat="server" Text='<%# Bind("Address") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>Email: </td>
                        <td>
                            <asp:TextBox ID="EmailTextBox" runat="server" Text='<%# Bind("Email") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>ContactPerson:</td>
                        <td>
                            <asp:TextBox ID="ContactPersonTextBox" runat="server" Text='<%# Bind("ContactPerson") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>Work: </td>
                        <td>
                            <asp:TextBox ID="WorkTextBox" runat="server" Text='<%# Bind("Work") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>Mobile: </td>
                        <td>
                            <asp:TextBox ID="MobileTextBox" runat="server" Text='<%# Bind("Mobile") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>Comments: </td>
                        <td>
                            <asp:TextBox ID="CommentsTextBox" runat="server" Text='<%# Bind("Comments") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>AssignedAgent: </td>
                        <td>
                            <asp:TextBox ID="AssignedAgentTextBox" runat="server" Text='<%# Bind("AssignedAgent") %>' Visible="False" />
                            <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="updateusers" DataTextField="username" DataValueField="lowereduser" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
                            </asp:DropDownList>
                        </td>
                    </tr>
                </table>
                <br />
                <table style="width: 100%;">
                    <tr>
                        <td>
                            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" />
                        </td>
                        <td>
                            <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                        </td>
                    </tr>
                </table>
            </EditItemTemplate>
            <InsertItemTemplate>
                <table style="width: 100%;">
                    <tr>
                        <td style="text-align: right; width: 80px">company: </td>
                        <td>
                            <asp:TextBox ID="companyTextBox" runat="server" Text='<%# Bind("company") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right; width: 80px">Address: </td>
                        <td>
                            <asp:TextBox ID="AddressTextBox" runat="server" Text='<%# Bind("Address") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right; width: 80px">Email: </td>
                        <td>
                            <asp:TextBox ID="EmailTextBox" runat="server" Text='<%# Bind("Email") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right; width: 80px">ContactPerson: </td>
                        <td>
                            <asp:TextBox ID="ContactPersonTextBox" runat="server" Text='<%# Bind("ContactPerson") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right; width: 80px">Work: </td>
                        <td>
                            <asp:TextBox ID="WorkTextBox" runat="server" Text='<%# Bind("Work") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right; width: 80px">Mobile: </td>
                        <td>
                            <asp:TextBox ID="MobileTextBox" runat="server" Text='<%# Bind("Mobile") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right; width: 80px">Comments: </td>
                        <td>
                            <asp:TextBox ID="CommentsTextBox" runat="server" Text='<%# Bind("Comments") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right; width: 80px">AssignedAgent: </td>
                        <td>
                            <asp:TextBox ID="AssignedAgentTextBox" runat="server" Text='<%# Bind("AssignedAgent") %>' Visible="False" />
                            <asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" DataSourceID="SqlDataUsers" DataTextField="username" DataValueField="lowereduser" OnLoad="DropDownList2_SelectedIndexChanged1" OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged1">
                            </asp:DropDownList>
                        </td>
                    </tr>
                </table>
                <br />
                <table style="width: 100%; margin-top: 0px;">
                    <tr>
                        <td>
                            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert" />
                        </td>
                        <td>
                            <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                        </td>
                    </tr>
                </table>
            </InsertItemTemplate>
            <ItemTemplate>
                <table style="width: 100%;">
                    <tr>
                        <td style="width: 80px; text-align: right;">company: </td>
                        <td>
                            <asp:Label ID="companyLabel" runat="server" Text='<%# Eval("company") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 80px; text-align: right;">Address: </td>
                        <td>
                            <asp:Label ID="AddressLabel" runat="server" Text='<%# Bind("Address") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 80px; text-align: right;">Email: </td>
                        <td>
                            <asp:Label ID="EmailLabel" runat="server" Text='<%# Bind("Email") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 80px; text-align: right;">ContactPerson: </td>
                        <td>
                            <asp:Label ID="ContactPersonLabel" runat="server" Text='<%# Bind("ContactPerson") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 80px; text-align: right;">Work: </td>
                        <td>
                            <asp:Label ID="WorkLabel" runat="server" Text='<%# Bind("Work") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 80px; text-align: right;">Mobile: </td>
                        <td>
                            <asp:Label ID="MobileLabel" runat="server" Text='<%# Bind("Mobile") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 80px; text-align: right;">Comments: </td>
                        <td>
                            <asp:Label ID="CommentsLabel" runat="server" Text='<%# Bind("Comments") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 80px; text-align: right;">AssignedAgent: </td>
                        <td>
                            <asp:Label ID="AssignedAgentLabel" runat="server" Text='<%# Bind("AssignedAgent") %>' />
                        </td>
                    </tr>
                </table>
                <br />
                <table style="width: 100%;">
                    <tr>
                        <td>
                            <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" />
                        </td>
                        <td>
                            <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" />
                        </td>
                        <td>
                            <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New" Text="New" />
                        </td>
                    </tr>
                </table>
                <br />
                <br />
            </ItemTemplate>
        </asp:FormView>
</p>
<p>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:inventorydatabase %>" DeleteCommand="DELETE FROM [inv_company] WHERE [company] = @company" InsertCommand="INSERT INTO [inv_company] ([company], [Address], [Email], [ContactPerson], [Work], [Mobile], [Comments], [AssignedAgent]) VALUES (@company, @Address, @Email, @ContactPerson, @Work, @Mobile, @Comments, @AssignedAgent)" SelectCommand="SELECT * FROM [inv_company]" UpdateCommand="UPDATE [inv_company] SET [Address] = @Address, [Email] = @Email, [ContactPerson] = @ContactPerson, [Work] = @Work, [Mobile] = @Mobile, [Comments] = @Comments, [AssignedAgent] = @AssignedAgent WHERE [company] = @company">
        <DeleteParameters>
            <asp:Parameter Name="company" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="company" Type="String" />
            <asp:Parameter Name="Address" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter Name="ContactPerson" Type="String" />
            <asp:Parameter Name="Work" Type="String" />
            <asp:Parameter Name="Mobile" Type="String" />
            <asp:Parameter Name="Comments" Type="String" />
            <asp:Parameter Name="AssignedAgent" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="Address" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter Name="ContactPerson" Type="String" />
            <asp:Parameter Name="Work" Type="String" />
            <asp:Parameter Name="Mobile" Type="String" />
            <asp:Parameter Name="Comments" Type="String" />
            <asp:Parameter Name="AssignedAgent" Type="String" />
            <asp:Parameter Name="company" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataUsers" runat="server" ConnectionString="<%$ ConnectionStrings:inventorydatabase %>" SelectCommand="SELECT * FROM [users]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="updateusers" runat="server" ConnectionString="<%$ ConnectionStrings:inventorydatabase %>" DeleteCommand="DELETE FROM [users];" InsertCommand="INSERT INTO [users] ([username], [lowereduser]) VALUES (@username, @lowereduser)" SelectCommand="SELECT * FROM [users]" UpdateCommand="UPDATE [users] SET [lowereduser] = @lowereduser WHERE [username] = @username">
        <DeleteParameters>
            <asp:Parameter Name="username" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:SessionParameter Name="username" SessionField="username" Type="String" />
            <asp:SessionParameter Name="lowereduser" SessionField="userlowered" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="lowereduser" Type="String" />
            <asp:Parameter Name="username" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>
</p>
</asp:Content>

